# 查看审批业务
from base.imp.base import base_imp, bases_imp
from selenium.webdriver.common.by import By

# 定于对象库层
class Home_page(base_imp):
    def __init__(self):
        super().__init__()
        #封装管理员元素
        self.username = By.XPATH, '//*[@id="app"]/div/div[2]/ul/div[3]/div[5]/span'
        #封装审批元素
        self.sp = By.XPATH, '//*[@id="app"]/div/div[1]/div/ul/div/a[9]/li'
        #封装查看审批元素
        self.ck = By.XPATH, '//*[@id="app"]/div/div[2]/section/div/div/div[2]/div[1]/div[3]/table/tbody/tr[1]/td[8]/div/a'
        # 定位审批记录
        self.lu = By.XPATH, '//*[@id="app"]/div/div[2]/section/div/div[2]/div[1]/strong'
    #定位封装元素
    def home_user(self):
        return self.get_element(self.username)
    def home_sp(self):
        return self.get_element(self.sp)
    def home_ck(self):
        return self.get_element(self.ck)
    def home_lu(self):
        return self.get_element(self.lu)
# 定义操作层
class Home_imp(bases_imp):
    def __init__(self):
        self.home_page = Home_page()
     # 获取username内容
    def imp_name(self):
        return self.home_page.home_user().text
    # 点击审批操作
    def imp_sp(self):
        self.home_page.home_sp().click()
    # 点击查看审批
    def imp_ck(self):
        self.home_page.home_ck().click()
    # 返回审批记录
    def imp_lu(self):
        return self.home_page.home_lu().text

# 定义业务层
class home_sta:
    def __init__(self):
        self.home_imp = Home_imp()

    # 进行获取user操作
    def user_sta(self):
        return self.home_imp.imp_name()
    # 进行查看审批内容操作
    def spck_sta(self):
        self.home_imp.imp_sp()
        self.home_imp.imp_ck()

    # 获取审批记录
    def lu_sta(self):
        return self.home_imp.imp_lu()